From: Georges Basile Stavracas Neto Date: Sat, 29 Jun 2019 04:26:08 +0000 (-0300) Subject: allView: Remove icon from folder when dropping outside X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~839^2^2~24 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=ec8b7bc7b2c39acbef2648ca1cb4d785ab95cd49;p=gnome-shell.git allView: Remove icon from folder when dropping outside When dropping an app icon to outside the folder, remove the app from that folder. GNOME Shell is already smart enough to figure out the setting changes and update the icons. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/664 --- diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 4cfea7e9c..6b3095eae 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -737,6 +737,37 @@ var AllView = class AllView extends BaseAppView { } } + _canAccept(source) { + if (!(source instanceof AppIcon)) + return false; + + let view = _getViewFromIcon(source); + if (!(view instanceof FolderView)) + return false; + + return true; + } + + handleDragOver(source) { + if (!this._canAccept(source)) + return DND.DragMotionResult.NO_DROP; + + return DND.DragMotionResult.MOVE_DROP; + } + + acceptDrop(source) { + if (!this._canAccept(source)) + return false; + + let view = _getViewFromIcon(source); + view.removeApp(source.app); + + if (this._currentPopup) + this._currentPopup.popdown(); + + return true; + } + inhibitEventBlocker() { this._nEventBlockerInhibits++; this._eventBlocker.visible = this._nEventBlockerInhibits == 0; @@ -1258,6 +1289,26 @@ var FolderView = class FolderView extends BaseAppView { return apps; } + + removeApp(app) { + let folderApps = this._folder.get_strv('apps'); + let index = folderApps.indexOf(app.id); + if (index >= 0) { + folderApps.splice(index, 1); + this._folder.set_strv('apps', folderApps); + } + + // If this is a categories-based folder, also add it to + // the list of excluded apps + let categories = this._folder.get_strv('categories'); + if (categories.length > 0) { + let excludedApps = this._folder.get_strv('excluded-apps'); + excludedApps.push(app.id); + this._folder.set_strv('excluded-apps', excludedApps); + } + + return true; + } }; var FolderIcon = class FolderIcon {